package com.monitor.controller;


import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.monitor.entity.ErpPayment;
import com.monitor.entity.ErpPaymentAl;
import com.monitor.service.ErpPaymentAlService;
import com.monitor.service.ErpPaymentService;
import com.monitor.util.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/erpPaymentAl")
@Api(description="付款,服务付款")
public class ErpPaymentController {

    @Resource
    private ErpPaymentService erpPaymentService;

    @Resource
    private ErpPaymentAlService erpPaymentAlService;

    @RequestMapping("/getOrderPays")
    @ApiOperation("采购管理-采购列表-付款,通过单号查询(下面的不知道是什么单)")
    @ApiImplicitParams({
           /* @ApiImplicitParam(name = "id", value = "id", required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "name", value = "部门名称", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "parentId", value = "父id", required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "customerCode", value = "客户编号", required = false, dataType = "int", paramType = "query"),*/
            @ApiImplicitParam(name = "formId", value = "付款单号", required = false, dataType = "int", paramType = "query")
    })
    public @ResponseBody
    Result<List<ErpPaymentAl>> getOrderPays(String formId) {
        Result<List<ErpPaymentAl>> result =new  Result<List<ErpPaymentAl>> ();
        try {
            List<ErpPaymentAl> form_id = erpPaymentAlService.selectList(new EntityWrapper<ErpPaymentAl>().eq("form_id", formId));
            result.setData(form_id);
        }catch (Exception e){
        e.printStackTrace();
        }

        return result;
    }    @RequestMapping("/getOrderPay")
    @ApiOperation("采购管理-采购列表-付款,通过单号查询(上面的付款单)")
    @ApiImplicitParams({
           /* @ApiImplicitParam(name = "id", value = "id", required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "name", value = "部门名称", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "parentId", value = "父id", required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "customerCode", value = "客户编号", required = false, dataType = "int", paramType = "query"),*/
            @ApiImplicitParam(name = "formId", value = "付款单号", required = false, dataType = "int", paramType = "query")
    })
    public @ResponseBody
    Result<ErpPayment> getOrderPay(String formId) {
        Result<ErpPayment> result =new Result<>();
        try {
            ErpPayment erpPayment = erpPaymentService.selectOne(new EntityWrapper<ErpPayment>().eq("form_id",formId));
            result.setData(erpPayment);
        }catch (Exception e){
        e.printStackTrace();
        }

        return result;
    }

}
